package com.bieber.redis.list.demo;

import com.bieber.democamp.util.RedisClient;

/**
 * Created by bieber on 2015/8/10.
 */
public class ListDemo {
    
    private static final String KEY ="products";
    public static void main(String[] args){
        /*for(int i=0;i<1000;i++){
            RedisClient.pushList(KEY.getBytes(),String.valueOf(i).getBytes());
        }*/
        for(int i=0;i<100;i++){
            Thread consumer = new Thread(){
                @Override
                public void run() {
                    for(int j=0;j<100;j++){
                       byte[] bytes = RedisClient.popList(KEY.getBytes());
                        if(bytes==null){
                            System.out.println(Thread.currentThread().getName()+" 商品已经卖完");
                        }else{
                            System.out.println(Thread.currentThread().getName()+" 恭喜你成功抢购商品"+new String(bytes));
                        }
                    }
                }
            };
            consumer.start();
        }
    }
}
